<?php
/* [DoYouHaoBaby!] (C)Dianniu From 2010.
   this($)*/

!defined('DYHB_PATH') && exit;

class TemplateGtkGladeWidgetCompiler_GtkFrame extends TemplateGtkGladeWidgetCompilerBase{

	protected function compileCreateWidget_(TemplateGtkGladeWidget $oObject){
		$sWidgetClass=$oObject->getWidgetClass();
		$sVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oObject);
		$sCompiled="\t\t{$sVariableName}=new {$sWidgetClass}();";
		$this->setStringInt_($oObject,$sCompiled,'shadow_type',false);// 阴影类型
		if(($sXAlign=$oObject->getProperty('label_xalign'))===null){// 标签 排列
			$sXAlign='0.5';
		}
		if(($sYAlign=$oObject->getProperty('label_yalign'))===null){
			$sYAlign='0.5';
		}
		$sCompiled.="\t\t{$sVariableName}->set_label_align({$sXAlign},{$sYAlign});";
		return $sCompiled;
	}

	protected function compileChildWidgetPacking_(TemplateGtkGladeWidget $oParentWidget,TemplateGtkGladeWidget $oChildWidget,TemplateGtkGladeWidgetPacking $oPacking){
		$sParentVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oParentWidget);// 父/子 窗体变量名
		$sChildWidgetVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oChildWidget);
		$sChildWidgetName=$oChildWidget->getWidgetId();// 子窗体名
		$sCompiled="\t\t{$sChildWidgetVariableName}=self::getWidget('{$sChildWidgetName}',\$arrObjectForSignal);";
		if($oPacking->getProperty('type')=='label_item'){// 标签窗体
			$sCompiled.="\t\t{$sParentVariableName}->set_label_widget({$sChildWidgetVariableName});";
		}
		else{// 内容窗体
			$sCompiled.="\t\t{$sParentVariableName}->add({$sChildWidgetVariableName});";
		}
		return $sCompiled;
	}

	static public function regToProcessorManager(ITemplateObjProcessorManager $oManager){
		$oManager->regProcessor(str_replace('TemplateGtkGladeWidgetCompiler_','',__CLASS__),__CLASS__);
	}

}
